/*
  +----------------------------------------------------------------------+
  | PHP Version 7                                                        |
  +----------------------------------------------------------------------+
  | Copyright (c) 1997-2018 The PHP Group                                |
  +----------------------------------------------------------------------+
  | This source file is subject to version 3.01 of the PHP license,      |
  | that is bundled with this package in the file LICENSE, and is        |
  | available through the world-wide-web at the following url:           |
  | http://www.php.net/license/3_01.txt                                  |
  | If you did not receive a copy of the PHP license and are unable to   |
  | obtain it through the world-wide-web, please send a note to          |
  | license@php.net so we can mail you a copy immediately.               |
  +----------------------------------------------------------------------+
  | Author:                                                              |
  +----------------------------------------------------------------------+
*/

/* $Id$ */

#ifndef PHP_SCARECROW_H
#define PHP_SCARECROW_H

extern zend_module_entry scarecrow_module_entry; /*声明Zend引擎注册当前扩展信息的结构体变量，并允许外部调用*/
#define phpext_scarecrow_ptr &scarecrow_module_entry /*定义一个宏来代替全局模块注册信息变量的地址*/

#define PHP_SCARECROW_VERSION "1.1.0" /* Replace with version number for your extension */
#define PHP_ECHO_VAR(z) printZval(z)
#define PHP_ECHO_VAR_P(z) PHP_ECHO_VAR(*(z))
#define PHP_ECHO_VAR_PP(z) PHP_ECHO_VAR_P(*(z))


#ifdef PHP_WIN32
#	define PHP_SCARECROW_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
#	define PHP_SCARECROW_API __attribute__ ((visibility("default")))
#else
#	define PHP_SCARECROW_API
#endif

#ifdef ZTS
#include "TSRM.h"
#endif

#define SCARECROW_DEBUG1

//log print
#define TRACE(fmt, ...) do { trace(__FILE__, __LINE__, __FUNCTION__, fmt, ##__VA_ARGS__); } while (0)
static inline void trace(const char *file, int line, const char* function, const char *fmt, ...);


/*
  	Declare any global variables you may need between the BEGIN
	and END macros here:

ZEND_BEGIN_MODULE_GLOBALS(scarecrow)
	zend_long  global_value;
	char *global_string;
ZEND_END_MODULE_GLOBALS(scarecrow)

声明一个全局的扩展使用的全局结构体 typedef struct _zend_scarecrow_globals {你的变量} zend_scarecrow_globals  ，主要用于全局变量存储、存储配置问题
*/
ZEND_BEGIN_MODULE_GLOBALS(scarecrow)
zend_long  age;
zend_long  sex;
char *isshuaige;
char *name;
char *address;
ZEND_END_MODULE_GLOBALS(scarecrow)
/* 声明全局变量 zend_scarecrow_globals scarecrow_globals */
ZEND_DECLARE_MODULE_GLOBALS(scarecrow)

/*类的操作句柄*/
//interface句柄对象地址
zend_class_entry *scarecrow_interface_handle = NULL; // interface handle
//scarecrow class对象地址
zend_class_entry *scarecrow_class_handle = NULL; // base class handle
//scarecreow child class对象地址
zend_class_entry *scarecrow_child_class_handle = NULL; // child class handle

/* 自定义函数区 */
//是否允许编译到PHP内核
PHP_FUNCTION(confirm_scarecrow_compiled);
//测试全局方法
PHP_FUNCTION(scarecrow_test);
//测试资源方法s
PHP_FUNCTION(scarecrow_resource);
//include文件
PHP_FUNCTION(scarecrow_include);
//构造函数
ZEND_METHOD(scarecrow, __construct);
//版本函数
ZEND_METHOD(scarecrow, version);
//获取作者
ZEND_METHOD(scarecrow, author);
//测试方法
ZEND_METHOD(scarecrow, test);
//测试数组
ZEND_METHOD(scarecrow, test_arr);
//将字符串转为小写
ZEND_METHOD(scarecrow, strtolower);
void strtolower(char *str, size_t strLen);
//将字符串转为大写
ZEND_METHOD(scarecrow, strtoupper);
//获取扩展名称
ZEND_METHOD(scarecrow, getExtName);
//文件加密s
ZEND_METHOD(scarecrow, addPwdFile);
//运行加密文件s
ZEND_METHOD(scarecrow, runPwdFile);

//scarecrow_child子类
ZEND_METHOD(scarecrow_child, version);
ZEND_METHOD(scarecrow_child, author_1);


// resource id
int scarecrow_string_resource_id = 0;

// resource type description
#define SCARECROW_STRING_RESOURCE_DTOR "scarecrow_string_resource"


/* Always refer to the globals in your function as SCARECROW_G(variable).
   You are encouraged to rename these macros something shorter, see
   examples in any other php module directory.
*/
/*
用于获取全局变量 scarecrow_globals 的值 ，其中v为某个属性的key
*/
#define SCARECROW_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(scarecrow, v)

#if defined(ZTS) && defined(COMPILE_DL_SCARECROW)
ZEND_TSRMLS_CACHE_EXTERN()
#endif

#endif	/* PHP_SCARECROW_H */

/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * End:
 * vim600: noet sw=4 ts=4 fdm=marker
 * vim<600: noet sw=4 ts=4
 */
